package com.xjd.edu.toolkit.metrics.config;

import com.xjd.edu.toolkit.metrics.web.WebErrorCounter;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.StandardEnvironment;

import javax.servlet.Filter;

/**
 * Web相关指标配置
 *
 * @author wangyu
 * @since 2023/2/3
 */
@ConditionalOnClass(Filter.class)
public class WebMetricsConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public WebErrorCounter webErrorCounter(MeterRegistry registry, StandardEnvironment environment) {
        return new WebErrorCounter(registry, environment);
    }

}
